#!/usr/bin/env python
# -*- encoding: utf-8 -*-
from app.app import Flask


def create_app():
    app = Flask(__name__)
    app.config.from_object('app.config.secure')
    app.config.from_object('app.config.setting')

    register_blueprints(app)
    register_plugin(app)
    return app


def register_plugin(app):
    from app.models.base import db
    db.init_app(app)
    with app.app_context():
        db.create_all()


def register_blueprints(app):
    from app.api import create_blueprint
    app.register_blueprint(create_blueprint(), url_prefix='/api')
